package com.hefei.rdd

import org.apache.spark.{SparkConf, SparkContext}

/**
 * @author caizhengjun
 * @date 2020/8/28 7:01 下午
 */
object Spark03_RDD_FlatMap {

  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName(this.getClass.getSimpleName)

    val sc: SparkContext = new SparkContext(conf)

    val value = sc.makeRDD(
      List(List(1, 2), 3, List(4, 5))
    )

    val value1 = value.flatMap {
      case list: List[Int] => list
      case d => List(d)
    }
    value1.collect().foreach(println)
    sc.stop()
  }
}
